//
//  $Id: StringAdditionTests.m 2 2007-09-07 18:35:43Z samson.etienne $
//  TCUBridgedClasses
//
//  Created by Simon Stapleton on Wed Oct 30 2002.
//  Copyright (c) 2001 Simon Stapleton. All rights reserved.
//

#import "StringAdditionTests.h"
#import "NSString+XMLAdditions.h"

@implementation StringAdditionTests

- (void) testElementNames {
  STAssertTrue ([@"name" isValidXMLElementName], @"");
  STAssertTrue ([@"n\357ame" isValidXMLElementName], @"");
  STAssertTrue ([@"ns:name" isValidXMLElementName], @"");
  STAssertTrue ([@"ns:n\351ame" isValidXMLElementName], @"");
  STAssertFalse ([@"" isValidXMLElementName], @"");
  STAssertFalse ([@"xmlname" isValidXMLElementName], @"");
  STAssertFalse ([@"3name" isValidXMLElementName], @"");
  STAssertFalse ([@"na me" isValidXMLElementName], @"");
  STAssertFalse ([@"na\\nme" isValidXMLElementName], @"");
  STAssertFalse ([@"ns:3name" isValidXMLElementName], @"");
  STAssertFalse ([@"ns::name" isValidXMLElementName], @"");
}

- (void) testAttributeValues {
  STAssertTrue ([@"attribute" isValidXMLAttributeValue], @"");
  STAssertTrue ([@"\341ttr\357bute" isValidXMLAttributeValue], @"");
  STAssertTrue ([@"attri bute" isValidXMLAttributeValue], @"");
  STAssertTrue ([@"attr\\tbute" isValidXMLAttributeValue], @"");
  STAssertTrue ([@"attr\\tib+-&&ute" isValidXMLAttributeValue], @"");
}

- (void) testQuoting {
  STAssertEqualObjects ([@"<>&&]]>>" stringByQuotingXMLEntities], @"&lt;&gt;&amp;&amp;]]&gt;&gt;", @"");
}

@end
